<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>乘方</title>
	</head>

	<body>
		<p><label>请输入x:</label>
			<input type="text" id="x" /></p>
		<p>
			<label>请输入y:</label>
			<input type="text" id="y" />
		</p>
		<p><input type="button" value="确定" onclick="xy()" /></p>
		<h1 id="jg"></h1>
		<script type="text/javascript">
			function xy() {
				var x = document.getElementById("x").value;
				var y = document.getElementById("y").value;
				var i = 1,
					s = 1;
				while(i <= y) {
					s = s * x;
					i++;
				}
				document.getElementById("jg").innerHTML =x+"<sup>"+y+"</sup>"+"="+s;
			}
		</script>
	</body>

</html>